package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmImageCodeMapper;
import cn.mcartoon.pojo.MmImageCode;
import cn.mcartoon.service.MmImageCodeService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmImageCodeServiceImpl implements MmImageCodeService {

    @Autowired
    private MmImageCodeMapper mmImageCodeMapper;

    public MmImageCode getMmImageCodeById(Long id){
        return mmImageCodeMapper.getMmImageCodeById(id);
    }

    public List<MmImageCode>	getMmImageCodeListByMap(Map<String,Object> param){
        return mmImageCodeMapper.getMmImageCodeListByMap(param);
    }

    public Integer getMmImageCodeCountByMap(Map<String,Object> param){
        return mmImageCodeMapper.getMmImageCodeCountByMap(param);
    }

    public Integer insertMmImageCode(MmImageCode mmImageCode){
            return mmImageCodeMapper.insertMmImageCode(mmImageCode);
    }

    public Integer updateMmImageCode(MmImageCode mmImageCode){
        return mmImageCodeMapper.updateMmImageCode(mmImageCode);
    }

    public Integer deleteMmImageCodeById(Long id){
        return mmImageCodeMapper.deleteMmImageCodeById(id);
    }

    public Integer batchDeleteMmImageCode(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmImageCodeMapper.batchDeleteMmImageCode(param);
    }

    public Page<MmImageCode> queryMmImageCodePageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmImageCodeMapper.getMmImageCodeCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmImageCode> mmImageCodeList = mmImageCodeMapper.getMmImageCodeListByMap(param);
        page.setList(mmImageCodeList);
        return page;
     }


}
